import React, { Component } from 'react'
import MainBanner from './MainBanner'
import MainProduct from './MainProduct'
// import axios from 'axios'

export class Main extends Component {
  constructor() {
    super()
    this.state = {
      banners: [],
      productList: [],
    }
  }

  // 网络请求
  /* componentDidMount() {
    axios
      .get('https://coderwhy-music.vercel.app/banner', {
        params: {
          type: 1,
        },
      })
      .then((res) => {
        console.log(res)
        this.setState({
          banners: res.data.data.banners.list,
          productList: res.data.productList.list,
        })
      })
  } */

  render() {
    const { banners, productList } = this.state

    return (
      <div>
        main组件
        <MainBanner banners={banners} title="轮播图" />
        <MainProduct productList={productList} />
      </div>
    )
  }
}

export default Main
